﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting.Messaging;

namespace ServiceController
{
    public delegate DataAccess.DataAccessResult DeleteDeploymentDelegate(String SubscriptionID, String CertificatePath, String ServiceName, String DeploymentSlot);
    public partial class ServiceController
    {
       
        DeleteDeploymentDelegate _DeleteDeploymentDelegate;
        public void DeleteDeploymentAsync(String SubscriptionID, String CertificatePath, String ServiceName, String DeploymentSlot, object UserState)
        {
            _DeleteDeploymentDelegate.BeginInvoke(SubscriptionID, CertificatePath, ServiceName, DeploymentSlot,
                new AsyncCallback(DeleteDeploymentCallback), UserState);
        }

        private void DeleteDeploymentCallback(IAsyncResult ar)
        {
            AsyncResult aresult = (AsyncResult)ar;
            DataAccess.DataAccessResult result = _DeleteDeploymentDelegate.EndInvoke(ar);
            OnDeleteDeploymentComplete(new ServiceControllerEventArgs()
            {
                error = result.Error,
                UserState = ar.AsyncState,
                IsOperationSuccessful = result.IsOperationSuccessful,
            });
        }

        private DataAccess.DataAccessResult DeleteDeployment(String SubscriptionID, String CertificatePath, String ServiceName, String DeploymentSlot)
        {
            DataAccess.DataAccessResult result = da.DeleteDeployment(SubscriptionID, CertificatePath, ServiceName, DeploymentSlot);
            return result;
        }
    }
}
